#ifndef __TASK_included
#define __TASK_included

#include <string>
#include <map>
#include <boost/shared_ptr.hpp>
#include "../client-common/VersionTag.h"

class CConnection;

using namespace std;
using namespace Client::Common;

class CTask {
	
	bool mFullySync;

public :
	CTask(bool full_sync) : mFullySync(full_sync) { }

	bool IsFullySync() { return mFullySync; }
	virtual bool Exec(boost::shared_ptr<CConnection> conn) = 0;
};

typedef boost::shared_ptr<CTask> TaskRef;

class CTaskCreator {

public :
	virtual TaskRef Create(VersionTagRef vt) = 0;
	virtual TaskRef CreateFullyTask(string& dev) = 0;
};

class CTaskFactory {

	static map<string, CTaskCreator*> mCreators;

public :

	static void RegisterCreator(string& tag, CTaskCreator* creator) {
		mCreators[tag] = creator;
	}

	static TaskRef Create(VersionTagRef vt);
	static bool ExecAllFullyTask(string& dev, boost::shared_ptr<CConnection> conn);
};



#endif